package tanxin;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class leetCode763_partitionLabels {
    public static void main(String[] args) {
        String a = "ababcbacadefegdehijhklij";
        leetCode763_partitionLabels aa = new leetCode763_partitionLabels();
        List<Integer> integers = aa.partitionLabels(a);
        System.out.println(1);
    }
    public List<Integer> partitionLabels(String s) {
        HashMap<Character,Integer> map = new HashMap<>();

        for (int i = 0; i < s.length(); i++) {
            map.put(s.charAt(i),i);
        }
        int pre = 0;
        List<Integer> result = new ArrayList<>();
        int maxIndex = Integer.MIN_VALUE;
        for (int i = 0; i < s.length(); i++) {
            maxIndex = Math.max(maxIndex,map.get(s.charAt(i)));
            if(i == maxIndex){
                result.add(i - pre + 1);
                pre = i + 1;
            }
        }
        return result;



    }
}
